package com.sunzm.flink.datastream.scala

import com.sunzm.flink.datastream.scala.beans.SensorReading
import org.apache.flink.streaming.api.scala.{DataStream, StreamExecutionEnvironment, _}

object SourceTest1_Collection_Scala {
  def main(args: Array[String]): Unit = {
    //1.创建执行的环境
    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment

    //2.从socket中获取数据
    val socketDataStream: DataStream[SensorReading] = env.fromCollection(Seq(
      SensorReading("sensor_1", 15451L, 15.7),
      SensorReading("sensor_6", 15451L, 25.7),
      SensorReading("sensor_7", 15451L, 18.7),
      SensorReading("sensor_10", 15451L, 5.7)))

    val fromElementsDataStream: DataStream[Int] = env.fromElements(1, 2, 3, 4, 58, 697)

    //4. 打印结果
    socketDataStream.print("socketDataStream")
    fromElementsDataStream.print("fromElementsDataStream")

    //5.执行
    env.execute(this.getClass.getSimpleName.stripSuffix("$"))
  }

}
